- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.7k
          Add --public for cargo add
          #13046
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
                
     Merged
            
            
  
    Add --public for cargo add
  
  #13046
              
            Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    | r? @epage (rustbot has picked a reviewer for you, use r? to override) | 
              
                    epage
  
              
              reviewed
              
                  
                    Nov 25, 2023 
                  
              
              
            
            
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a quick pass. I know that I at Ieast need to look at tests closer.
              
                    epage
  
              
              reviewed
              
                  
                    Nov 26, 2023 
                  
              
              
            
            
        
          
                tests/testsuite/cargo_add/overwrite_public_with_no_public/mod.rs
              
                Outdated
          
            Show resolved
            Hide resolved
        
      
              
                    epage
  
              
              reviewed
              
                  
                    Nov 26, 2023 
                  
              
              
            
            
              
                    epage
  
              
              reviewed
              
                  
                    Nov 26, 2023 
                  
              
              
            
            
aac8bc1    to
    5095356      
    Compare
  
    
              
                    epage
  
              
              reviewed
              
                  
                    Nov 27, 2023 
                  
              
              
            
            
              
                    epage
  
              
              reviewed
              
                  
                    Nov 27, 2023 
                  
              
              
            
            
              
                    epage
  
              
              reviewed
              
                  
                    Nov 30, 2023 
                  
              
              
            
            
              
                    epage
  
              
              reviewed
              
                  
                    Nov 30, 2023 
                  
              
              
            
            
| Looks great, thanks! @bors r+ | 
| ☀️ Test successful - checks-actions | 
  This was referenced Dec 1, 2023 
      
    
  bors 
      added a commit
        to rust-lang-ci/rust
      that referenced
      this pull request
    
      Dec 2, 2023 
    
    
      
  
    
      
    
  
Update cargo 25 commits in 26333c732095d207aa05932ce863d850fb309386..58fb23140972092a12f7011d17a7db1d99e3eacf 2023-11-28 20:07:39 +0000 to 2023-12-02 14:15:16 +0000 - test(install): use TCP connection instead of thread sleep (rust-lang/cargo#13099) - test(mdman): Switch to snapbox (rust-lang/cargo#13098) - Include declared list of features in fingerprint for `-Zcheck-cfg` (rust-lang/cargo#13012) - chore(deps): update compatible (rust-lang/cargo#13083) - chore(ci): Always update gix packages together (rust-lang/cargo#13093) - chore(deps): update rust crate windows-sys to 0.52 (rust-lang/cargo#13089) - refactor(toml): Decouple logic from schema (rust-lang/cargo#13080) - Have cargo add --optional <dep> create a <dep> = "dep:<dep> feature (rust-lang/cargo#13071) - Add `--public` for `cargo add` (rust-lang/cargo#13046) - chore(deps): update rust crate toml_edit to 0.21.0 (rust-lang/cargo#13088) - chore(deps): update rust crate rusqlite to 0.30.0 (rust-lang/cargo#13087) - test(trim-paths): exercise with real world debugger (rust-lang/cargo#13091) - Fixed uninstall a running binary failed on Windows (rust-lang/cargo#13053) - chore(deps): update rust crate itertools to 0.12.0 (rust-lang/cargo#13086) - Add more options to registry test support. (rust-lang/cargo#13085) - Don't filter on workspace members when scraping doc examples (rust-lang/cargo#13077) - Remove the outdated comment (rust-lang/cargo#13076) - fix(resolver): Remove unused public-deps error handling (rust-lang/cargo#13036) - Fixes error count display is different when there's only one error left (rust-lang/cargo#12484) - fix: reorder `--remap-path-prefix` flags for `-Zbuild-std` (rust-lang/cargo#13065) - remove jobserver env var in some tests (rust-lang/cargo#13072) - doc: clarify different target has different set of `CARGO_CFG_*` values (rust-lang/cargo#13069) - docs: remove review capacity notice in PR template (rust-lang/cargo#13070) - chore(deps): update rust crate openssl to 0.10.60 [security] (rust-lang/cargo#13068) - fix(resolver): De-prioritize no-rust-version in MSRV resolver (rust-lang/cargo#13066) r? ghost
    
  bors 
      added a commit
        to rust-lang-ci/rust
      that referenced
      this pull request
    
      Dec 2, 2023 
    
    
      
  
    
      
    
  
Update cargo 27 commits in 26333c732095d207aa05932ce863d850fb309386..623b788496b3e51dc2f9282373cf0f6971a229b5 2023-11-28 20:07:39 +0000 to 2023-12-02 18:10:03 +0000 - docs(book): make old title anchorable (rust-lang/cargo#13102) - Revert "chore(deps): update rust crate openssl to 0.10.60 [security]" (rust-lang/cargo#13101) - test(install): use TCP connection instead of thread sleep (rust-lang/cargo#13099) - test(mdman): Switch to snapbox (rust-lang/cargo#13098) - Include declared list of features in fingerprint for `-Zcheck-cfg` (rust-lang/cargo#13012) - chore(deps): update compatible (rust-lang/cargo#13083) - chore(ci): Always update gix packages together (rust-lang/cargo#13093) - chore(deps): update rust crate windows-sys to 0.52 (rust-lang/cargo#13089) - refactor(toml): Decouple logic from schema (rust-lang/cargo#13080) - Have cargo add --optional <dep> create a <dep> = "dep:<dep> feature (rust-lang/cargo#13071) - Add `--public` for `cargo add` (rust-lang/cargo#13046) - chore(deps): update rust crate toml_edit to 0.21.0 (rust-lang/cargo#13088) - chore(deps): update rust crate rusqlite to 0.30.0 (rust-lang/cargo#13087) - test(trim-paths): exercise with real world debugger (rust-lang/cargo#13091) - Fixed uninstall a running binary failed on Windows (rust-lang/cargo#13053) - chore(deps): update rust crate itertools to 0.12.0 (rust-lang/cargo#13086) - Add more options to registry test support. (rust-lang/cargo#13085) - Don't filter on workspace members when scraping doc examples (rust-lang/cargo#13077) - Remove the outdated comment (rust-lang/cargo#13076) - fix(resolver): Remove unused public-deps error handling (rust-lang/cargo#13036) - Fixes error count display is different when there's only one error left (rust-lang/cargo#12484) - fix: reorder `--remap-path-prefix` flags for `-Zbuild-std` (rust-lang/cargo#13065) - remove jobserver env var in some tests (rust-lang/cargo#13072) - doc: clarify different target has different set of `CARGO_CFG_*` values (rust-lang/cargo#13069) - docs: remove review capacity notice in PR template (rust-lang/cargo#13070) - chore(deps): update rust crate openssl to 0.10.60 [security] (rust-lang/cargo#13068) - fix(resolver): De-prioritize no-rust-version in MSRV resolver (rust-lang/cargo#13066)
    
  bors 
      added a commit
      that referenced
      this pull request
    
      Dec 4, 2023 
    
    
      
  
    
      
    
  
chore(test): remove unnecesary packages and versions for `optionals` tests ### What does this PR try to resolve? This PR was inspired by #13046 (comment) and #12189. There is unnecessary to keep more pacakages and versions on test case and the more pacakage added, the more test time and CI resource taken up. And this PR also fixed a issue that `overwrite_optional_with_optional` had not been added to `tests/testsuite/cargo_add/mod.rs`. ### How should we test and review this PR? ### Additional information
    
  epage 
      added a commit
        to epage/cargo
      that referenced
      this pull request
    
      Dec 6, 2023 
    
    
      
  
    
      
    
  
This is a step towards #44663. When discussing inheriting this field for rust-lang#13046, we realized that we should probably start by disallowing inheritance. We can always add it later. imo the principle of what should be inherited is what is truely common among dependencies. For example, we don't allow removing features. Public should not be universally applied and likely should be explicit so its not over-done, especially since we can't (atm) lint for when a public dependency could be non-public. This reverts parts of rust-lang#12817
    
  epage 
      added a commit
        to epage/cargo
      that referenced
      this pull request
    
      Dec 6, 2023 
    
    
      
  
    
      
    
  
This is a step towards #44663. When discussing inheriting this field for rust-lang#13046, we realized that we should probably start by disallowing inheritance. We can always add it later. imo the principle of what should be inherited is what is truely common among dependencies. For example, we don't allow removing features. Public should not be universally applied and likely should be explicit so its not over-done, especially since we can't (atm) lint for when a public dependency could be non-public. This reverts parts of rust-lang#12817
    
  bors 
      added a commit
      that referenced
      this pull request
    
      Dec 6, 2023 
    
    
      
  
    
      
    
  
fix(toml): Disallow inheriting of dependency public status ### What does this PR try to resolve? This is a step towards rust-lang/rust#44663. When discussing inheriting this field for #13046, we realized that we should probably start by disallowing inheritance. We can always add it later. imo the principle of what should be inherited is what is truely common among dependencies. For example, we don't allow removing features. Public should not be universally applied and likely should be explicit so its not over-done, especially since we can't (atm) lint for when a public dependency could be non-public. ### How should we test and review this PR? ### Additional information This reverts parts of #12817
      
        
      
      
  
    28 tasks
  
    
  bors 
      added a commit
      that referenced
      this pull request
    
      Jan 9, 2024 
    
    
      
  
    
      
    
  
doc: add `public` info in `cargo-add` man page. ### What does this PR try to resolve? follow up #13046 add `public/private` explanation for `cargo-add` in man page. ### How should we test and review this PR? ### Additional information
    
  bors 
      added a commit
      that referenced
      this pull request
    
      Jan 11, 2024 
    
    
      
  
    
      
    
  
doc: add `public` info in `cargo-add` man page. ### What does this PR try to resolve? follow up #13046 add `public/private` explanation for `cargo-add` in man page. ### How should we test and review this PR? ### Additional information The help info would be like this - `cargo help add` ``` --public Mark the dependency as public. The dependency can be referenced in your library’s public API. Unstable (nightly-only) <https://doc.rust-lang.org/cargo/reference/unstable.html#public-dependency> --no-public Mark the dependency as private. While you can use the crate in your implementation, it cannot be referenced in your public API. Unstable (nightly-only) <https://doc.rust-lang.org/cargo/reference/unstable.html#public-dependency> ``` - `cargo add -h` ``` --public Mark the dependency as public (unstable) --no-public Mark the dependency as private (unstable) ``` - `cargo add --help` ``` --public Mark the dependency as public (unstable) The dependency can be referenced in your library's public API. --no-public Mark the dependency as private (unstable) While you can use the crate in your implementation, it cannot be referenced in your public API. ```
    
  bors 
      added a commit
      that referenced
      this pull request
    
      Jan 11, 2024 
    
    
      
  
    
      
    
  
doc: add `public` info in `cargo-add` man page. ### What does this PR try to resolve? follow up #13046 add `public/private` explanation for `cargo-add` in man page. ### How should we test and review this PR? ### Additional information The help info would be like this - `cargo help add` ``` --public Mark the dependency as public. The dependency can be referenced in your library’s public API. Unstable (nightly-only) <https://doc.rust-lang.org/cargo/reference/unstable.html#public-dependency> --no-public Mark the dependency as private. While you can use the crate in your implementation, it cannot be referenced in your public API. Unstable (nightly-only) <https://doc.rust-lang.org/cargo/reference/unstable.html#public-dependency> ``` - `cargo add -h` ``` --public Mark the dependency as public (unstable) --no-public Mark the dependency as private (unstable) ``` - `cargo add --help` ``` --public Mark the dependency as public (unstable) The dependency can be referenced in your library's public API. --no-public Mark the dependency as private (unstable) While you can use the crate in your implementation, it cannot be referenced in your public API. ```
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      Labels
      
    A-cli
  Area: Command-line interface, option parsing, etc. 
  
    A-manifest
  Area: Cargo.toml issues 
  
    Command-add
  
    S-waiting-on-bors
  Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 
  
    Z-public-dependency
  Nightly: public-dependency 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
What does this PR try to resolve?
Complete #13037
This PR want to add
--public/--no publicflag forcargo addNote: this assumes we'll remove workspace inheritance support for
publicas it sounds like we'll be reverting it rust-lang/rust#44663 (comment). If we decide to keep workspace inheritance, we'll need to come back and update this.How should we test and review this PR?
Most of Code were reference
cargo add --optional, So can reviewed the new code based on the part ofoptionalcode.The new testcases were origin from the
cargo add --optionalpart.publictestcase:there is no dependencies and will be addpublicdependencies.no_publictestcase: there is no dependencies and will be addno_publicdependencies.overwrite_publictestcase: the dependencies already exists but will be overwrite withpublic.overwrite_no_publictestcase: the dependencies already exists but will be overwrite withno_public.overwrite_public_with_no_publictestcase: the dependencies already marked asno_publicand will be overwrite withpublic.overwrite_no_public_with_publictestcase: the dependencies already marked aspublicand will be overwrite withno_public.